﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ServeNHL.Models
{
    public class VCLViewModel
    {
        public List<VCL_MEMBERS> VCLMembers { get; set; }
        public VOLUNTEER_CONTROL_LIST VCL { get; set; }

        public List<VCLViewModel> getVCLs()
        {
            var list = new List<VCLViewModel>();

            using (var dbconn = new fclick_dbEntities())
            {
                var vcl = dbconn.VOLUNTEER_CONTROL_LIST.OrderBy(v => v.STATUS).ToList();

                foreach (var v in vcl)
                {
                    var members = dbconn.VCL_MEMBERS.Where(m => m.VCL_ID == v.VCL_ID).ToList();
                    var vm = new VCLViewModel();
                    vm.VCL = v;
                    vm.VCLMembers = members;
                    list.Add(vm);
                }
            }

            return list;
        }

        public static List<VOLUNTEER_CONTROL_LIST> getActiveVCLForDropdown()
        {
            var vcl = new List<VOLUNTEER_CONTROL_LIST>();
            using (var dbconn = new fclick_dbEntities())
            {
                vcl = dbconn.VOLUNTEER_CONTROL_LIST.Where(v => v.STATUS == "Active").ToList();

            }
            return vcl;
        }

        public bool saveVCLList(VCLViewModel vcl)
        {
            bool isSaved = false;
            var vclObj = new VOLUNTEER_CONTROL_LIST();

            var vlcID = vclObj.saveVCL(vcl.VCL);
            

            return isSaved;
        }
    }// End of class VCLViewModel
}